 <%@ page contentType="text/html; charset=UTF-8"%>
 <%@ taglib prefix="s" uri="/struts-tags"%>
 <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
 <html>
    <head>
       <link href="
       <s:url value="resources/css/main.css"/>
       " rel="stylesheet" type="text/css"/>
    </head>
    <body>
       <center>

          <table align=center>
             <tr>
                <td>
                   <h1>
                      <s:if test="OrderDetail==null || OrderDetail.orderDetailId == null">
                         <s:text name="label.orderDetail.add"/>
                      </s:if>
                      <s:else>
                         <s:text name="label.orderDetail.edit"/>
                      </s:else>
                   </h1>
                </td>
             </tr>
          </table>
          <table width=600 align=center>
             <tr>
                <td><a href="getAllOrderDetails.html">Click Here to View Employees</a></td>
             </tr>
          </table>
          <table>
             <tr>
                <td align="left" style="font:bold;color:red">
                   <s:fielderror/>
                   <s:actionerror/>
                   <s:actionmessage/>
                </td>
             </tr>
          </table>
          <s:form>
             <table align="center" class="borderAll">

                <s:hidden name="criteria" value="A0"/>
                <s:hidden name="criteriaSubId" value="1"/>

                <tr>
                   <td class="tdLabel">
                      <s:text name="label.orderDetail.item"/>
                   </td>
                   <td>
                           <s:select name="orderDetail.item.itemId"
                             list="#session.itemIdList"
                             headerKey="-1"
                             headerValue="Select"
                             listKey="itemId"
                             listValue="itemId"
                             multiple="false"
                             />
                   </td>
                </tr>

                <tr>
                   <td class="tdLabel">
                      <s:text name="label.orderDetail.quantity"/>
                   </td>
                   <td>
                      <s:textfield name="orderDetail.quantity" size="30"/>
                   </td>
                </tr>

             </table>
             <br/>
             <table>
                <tr>
                   <td>


                     <s:if test="OrderDetail==null || OrderDetail.orderDetailId == null">
                        <s:submit action="orderDetailInsert" key="button.label.submit" cssClass="butStnd"/>
                      </s:if>
                      <s:else>
                         <s:submit action="orderDetailUpdate" key="button.label.submit" cssClass="butStnd"/>
                      </s:else>

                   </td>
                   <td>
                      <s:reset key="button.label.cancel" cssClass="butStnd" action="orderDetailInsertOrUpdate" />
                   </td>
                <tr>
             </table>
          </s:form>

          <table align=center class="borderAll">
              <tr>
                  <th><s:text name="label.orderDetail.item"/></th>
                  <th><s:text name="label.item.itemName"/></th>
                  <th><s:text name="label.orderDetail.quantity"/></th>
                  <th><s:text name="label.orderDetail.lineAmount"/></th>
                  <th>&nbsp;</th>
              </tr>
              <s:iterator value="orderDetails" status="status">
                  <tr class="<s:if test="#status.even">even</s:if><s:else>odd</s:else>">
                      <td class="nowrap"><s:property value="item.itemId"/></td>
                      <td class="nowrap"><s:property value="item.itemName"/></td>
                      <td class="nowrap"><s:property value="quantity"/></td>
                      <td class="nowrap"><s:property value="lineAmount"/></td>
                      <td class="nowrap">
                                      	<s:url id="update" action="orderDetailSetUpForUpdate">
                      		       		   <s:param name="orderDetail.item.itemId" value="id"/>
                      		       		</s:url>
                                      <s:a href="%{update}">Edit</s:a>
                                      &nbsp;&nbsp;&nbsp;
                                      <s:url id="delete" action="orderDetailDelete">
                      		       		   <s:param name="orderDetail.item.itemId" value="id"/>
                      		       		</s:url>
                                      <s:a href="%{delete}">Delete</s:a>
                                  </td>

                  </tr>
          	 </s:iterator>
              </table>
              <table align=center>
                          <tr>
                             <td>
                                <h1>
                                   <s:if test="%{getOrderDetails().isEmpty()}">

                                   </s:if>
                                   <s:else>

                                                <tr>
                                                   <s:url id="insertItem" action="custOrderSetUpForInsert"/>
                                                   <td>
                                                      <s:a href="%{insertItem}" target="body" > Proceed to Add Cust Order</s:a>
                                                   </td>
                                                </tr>


                                   </s:else>
                                </h1>
                             </td>
                          </tr>
              </table>
       </center>
    </body>
 </html>